package com.atguigu.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.Map;

/*
* excel读取操作的监听器
* */
public class ExcelListener extends AnalysisEventListener<DemoData> {

    /*调用最终方法实现读取操作*/
    public static void main(String[] args) {
        /*实现excel读操作*/
        String filename="D:\\write.xlsx";
        EasyExcel.read(filename,DemoData.class,new ExcelListener()).sheet().doRead();
    }

    /*一行一行的读取excel里面的内容*/
    @Override
    public void invoke(DemoData demoData, AnalysisContext analysisContext) {
        /*一行一行的读取内容*/
        System.out.println("****:"+demoData);
    }


    /*读取表头里面的内容*/
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头："+headMap);
    }


    /*读取完成之后做的事情*/
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        System.out.println("我读取完成了");
    }
}